<template>
  <div class="campus-binhai">
    <header>
      <p>温州理工滨海校区</p>
    </header>

    <div class="search-container">
      <input 
        type="text" 
        v-model="studentId" 
        placeholder="请输入学号" 
        @keyup.enter="searchStudent"
      />
      <button @click="searchStudent">搜索</button>
    </div>

    <div class="student-info" v-if="currentStudent">
      <h2>学生信息</h2>
      <p>学号: {{ currentStudent.id }}</p>
      <p>姓名: {{ currentStudent.name }}</p>
      <p>年龄: {{ currentStudent.age }}</p>
      <p>专业: {{ currentStudent.major }}</p>
    </div>

    <div class="no-result" v-if="searchPerformed && !currentStudent">
      <p>未找到该学号对应的学生信息</p>
    </div>
  </div>
</template>


<script>
export default {
  name: 'CampusBinhai',
  data() {
    return {
      studentId: '',
      searchPerformed: false,
      currentStudent: null,
      // 模拟学生数据库
      students: [
        { id: '123456', name: '李小明', age: 18, major: '计算机科学' },
        { id: '234567', name: '张小红', age: 19, major: '软件工程' }
      ]
    }
  },
  methods: {
    searchStudent() {
      this.searchPerformed = true;
      this.currentStudent = this.students.find(student => student.id === this.studentId);
    }
  }
}
</script>

<style scoped>
.campus-binhai {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  font-family: Arial, sans-serif;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

h1 {
  color: #333;
}

.search-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

input {
  padding: 10px;
  width: 200px;
  margin-right: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

button {
  padding: 10px 20px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background-color: #45a049;
}

.student-info, .no-result {
  background-color: #f9f9f9;
  padding: 20px;
  border-radius: 4px;
  margin-top: 20px;
}

.student-info p {
  margin: 10px 0;
}
</style>
